﻿@using Dignite.Abp.DynamicForms.Switch
@inherits FormViewComponentBase<SwitchFormControl,SwitchConfiguration>

<Field>
    <FieldLabel>@Field.DisplayName</FieldLabel>
    <FieldBody Margin="Margin.IsAuto">                 
        @if (value.HasValue)
        {
            <Icon class="text-success" Name="IconName.Check" />
        }
        else
        {
            <Icon class="text-success" Name="IconName.Times" />
        }
    </FieldBody>
</Field>


@code{
    private bool? value = null;

    protected override void OnInitialized()
    {
        base.OnInitialized();
        if (Field.Value != null)
        {
            bool convertValue;
            if (bool.TryParse(Field.Value.ToString(), out convertValue))
            {
                value = convertValue;
            }
        }
    }
}